Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplication of homonyms #2746

Merged

Conversation

JGamache-autodesk
Copy link
Collaborator

Fixes: Two items that would resolve to the same path after name conflict resolution actually end up being duplicated into the same name.

So duplicating "bob1" and "bob2" in the same selection would result in a single "bob3" and a missing "bob4".

The code now creates and executes sub-duplication tasks in the main loop to make sure the name conflict resolution sees the complete picture.

Fixes: Two items that would resolve to the same path after name conflict
resolution actually end up being duplicated into the same name.

So duplicating "bob1" and "bob2" in the same selection would result in a
single "bob3" and a missing "bob4".

The code now creates and executes sub-duplication tasks in the main loop
to make sure the name conflict resolution sees the complete picture.
for (auto&& item : selection) {
if (UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast<UsdSceneItem>(item)) {
// Currently unordered_map since we need to streamline the targetItem override.
_perItemCommands[item->path()] = UsdUndoDuplicateCommand::create(usdItem);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't pre-create all the tasks because the name conflict resolution code will not incrementally see the new paths.

@JGamache-autodesk JGamache-autodesk added ufe Related to UFE component in Maya ufe-usd Related to UFE-USD plugin in Maya-Usd labels Nov 25, 2022
@JGamache-autodesk
Copy link
Collaborator Author

Pre-flight passed. Only one random test failure on the usual testUsdExportPackage.

hodoulp
hodoulp previously approved these changes Nov 28, 2022
UsdSceneItem::Ptr usdItem = std::dynamic_pointer_cast<UsdSceneItem>(item);
if (usdItem) {
canDuplicate = true;
break;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Comment] Would it be interesting to continue the loop to remove null usdItem from the list?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. allowing to remove lines 88 to 90 & perhaps right away create a list/set of UsdSceneItem::Ptr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. Anyway this will be revisited at some point to fix MAYA-125854 and we will also remove all usdItems that have a parent in the list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that was a great idea and it also provided a very efficient way to fix MAYA-125854. Done.

As inspired by a review comment.
batchOpsHandler = ufe.RunTimeMgr.instance().batchOpsHandler(geomItem.runTimeId())
self.assertIsNotNone(batchOpsHandler)

# Put then in a selection, making sure one child item is first, and that another child item is last.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit] Typo: "then" -> "them"

Copy link
Collaborator

@stefanminning-autodesk stefanminning-autodesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

hodoulp
hodoulp previously approved these changes Nov 30, 2022
@JGamache-autodesk JGamache-autodesk added the ready-for-merge Development process is finished, PR is ready for merge label Dec 1, 2022
Copy link
Collaborator

@stefanminning-autodesk stefanminning-autodesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@neilh-adsk neilh-adsk merged commit e917069 into dev Dec 1, 2022
@neilh-adsk neilh-adsk deleted the gamaj/fix_duplicate_collision_on_similarly_named_nodes branch December 1, 2022 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe Related to UFE component in Maya ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants